package videojuegoalpha;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
public class Character{
    int positionX,dx,positionY,y,nx,nx2,left,dy;
    boolean avoidedObstacle, powerUp;
    //lol
    BufferedImage characterSheet, powerUpSprites, runSprites, jumpSprites, slideSprites;    
    ImageIcon s = new ImageIcon("still.png");
    ImageIcon j= new ImageIcon("jump.png");
    ImageIcon l = new ImageIcon("left.png");
    ImageIcon d= new ImageIcon("dash.png");
    Image still = s.getImage();
    Image jump = j.getImage();
    Image dash = d.getImage();
    Image actual;
    int lifes;
    boolean isAlive;
    boolean keyAllowed; //esta variable indica cuando se prenden o apagan los listeners
    boolean dashPressed;// para saber si la tecla abajo esta siendo presionada
    
    // Métodos
    
    public Character() {
                positionX = 150;
                left = 150;
                nx = 1;
                nx2= 800;
                y = 172;
                dx=1;
                actual=still;
                lifes=3;
                isAlive=true;
                keyAllowed=true;
                dashPressed=false;
        }
    
    public void move() {
        positionX = positionX + dx;
        nx2 = nx2 + dx;
        nx = nx + dx;
    }
    
        public Rectangle getBounds(){
        return new Rectangle(positionX,positionY, actual.getWidth(null), actual.getHeight(null));
    }
    
    
    public void keyPressed(KeyEvent e) {
        if(keyAllowed){
            
        int key = e.getKeyCode();
        
        if (key == KeyEvent.VK_SPACE) {
            dy = 1;
            actual = jump;
        }
        
        if (key == KeyEvent.VK_DOWN) {
            actual = dash;
            dashPressed=true;
            
        }
        
        if (key == KeyEvent.VK_ESCAPE) {
            System.exit(0);
        }
        
        }
    }

    public void keyReleased(KeyEvent e) {


        int key = e.getKeyCode();

        if (key == KeyEvent.VK_SPACE) {
            dy = 0;
        }
        if (keyAllowed) {
            if (key == KeyEvent.VK_DOWN) {
                actual = still;
                dashPressed=false;
            }
        }
    }
    
//    public BufferedImage run(){
//        return null;
//    }
//    
//    public BufferedImage jump(){
//        return null;
//    }
//    
//    public BufferedImage slide(){
//        return null;
//    }
//    
//    public boolean death(){
//        return false;
//    }
//    
//    public void Checkpoint(/*deathPosition*/){
//        
//    }
//    
//    public int position(int positionX, int positionY){
//        return 0;
//    }
//    
//    public BufferedImage drawCharacter(){
//        return null;
//    }
    
    // Hacer método que detecte una colisión con un obstáculo así también una que detecte
    // Colisión con un powerUp, BoundingBox
    
    
    // Getters y Setters 

    public int getnX() {
        return nx;
    }

    public void setnX(int nx) {
        this.nx = nx;
    }

    public int getnX2() {
        return nx2;
    }

    public void setnX2(int nx2) {
        this.nx2 = nx2;
    }

    public int getDx() {
        return dx;
    }

    public void setDx(int dx) {
        this.dx = dx;
    }
    
    
    public boolean getPowerUp() {
        return powerUp;
    }

    public void setPowerUp(boolean getPowerUp) {
        this.powerUp = getPowerUp;
    }
    
    public boolean getAvoidedObstacle() {
        return avoidedObstacle;
    }

    public void setAvoidedObstacle(boolean avoidObstacle) {
        this.avoidedObstacle = avoidObstacle;
    }

    public BufferedImage getCharacterSheet() {
        return characterSheet;
    }

    public void setCharacterSheet(BufferedImage characterSheet) {
        this.characterSheet = characterSheet;
    }

    public BufferedImage getJumpSprites() {
        return jumpSprites;
    }

    public void setJumpSprites(BufferedImage jumpSprites) {
        this.jumpSprites = jumpSprites;
    }
    
    public void setJump(Image i){
        jump=i;
    }

    public int getPositionX() {
        return positionX;
    }

    public void setPositionX(int positionX) {
        this.positionX = positionX;
    }

    public int getPositionY() {
        return positionY;
    }

    public void setPositionY(int positionY) {
        this.positionY = positionY;
    }

    public BufferedImage getPowerUpSprites() {
        return powerUpSprites;
    }

    public void setPowerUpSprites(BufferedImage powerUpSprites) {
        this.powerUpSprites = powerUpSprites;
    }
    
    public Image getImage() {
        return actual;
    }
    
    public void setImage(Image i){
        actual=i;
    }

    public BufferedImage getRunSprites() {
        return runSprites;
    }

    public void setRunSprites(BufferedImage runSprites) {
        this.runSprites = runSprites;
    }

    public BufferedImage getSlideSprites() {
        return slideSprites;
    }

    public void setSlideSprites(BufferedImage slideSprites) {
        this.slideSprites = slideSprites;
    } 
}
